<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id ="but">取消延时执行</button>
</body>
<script>
    var but = document.getElementById("but");
    //可以延迟执行一段代码
    var timed = setTimeout(function(){

        alert("我是你爸爸");
    },2000);

    //clearTimeout(id)
    //清楚特定id的延迟执行
    but.onclick = function(){
        clearTimeout(timed);
    }
</script>
</html>